package com.hsh.erp.controller;

import com.hsh.erp.domain.common.Result;
import com.hsh.erp.domain.dto.ProductDTO;
import com.hsh.erp.domain.vo.ProductVO;
import com.hsh.erp.service.ProductService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author USER
 * @description 针对表【product】的数据库操作Service实现
 * @createDate 2024-05-30 16:21:43
 */
@RestController
@RequestMapping("/product")
@Tag(name = "商品", description = "商品")
public class ProductController {

    @Resource
    private ProductService productService;

    /**
     * 获取所有未删除的商品
     *
     * @param
     * @return
     */
    @GetMapping("/all")
    @Operation(summary = "获取所有未删除的商品")
    public Result<List<ProductDTO>> geAll() {
        return productService.getAll();
    }

    /**
     * 列表查询
     *
     * @param productVO
     * @return
     */
    @GetMapping("/list")
    @Operation(summary = "列表查询")
    public Result<List<ProductDTO>> getList(ProductVO productVO) {
        return productService.getList(productVO);
    }

    /**
     * 修改一条记录
     *
     * @param productVO
     * @return
     */
    @PostMapping("/updateOne")
    @Operation(summary = "修改一条记录")
    public Result updateOne(@RequestBody ProductVO productVO) {
        return productService.updateOne(productVO);
    }

    /**
     * 删除一条记录
     *
     * @param productVO
     * @return
     */
    @PostMapping("/deleteOne")
    @Operation(summary = "删除一条记录")
    public Result deleteOne(@RequestBody ProductVO productVO) {
        return productService.deleteOne(productVO);
    }

    /**
     * 新增一条记录
     *
     * @param productVO
     * @return
     */
    @PostMapping("/addOne")
    @Operation(summary = "新增一条记录")
    public Result addOne(@Valid @RequestBody ProductVO productVO) {
        return productService.addOne(productVO);
    }


    /**
     * 列表导出
     *
     * @param productVO
     * @return
     */
    @GetMapping("/export")
    @Operation(summary = "列表导出")
    public Result export(ProductVO productVO) {
        return productService.export(productVO);
    }

}




